	<script>
		$(document).ready(function(e) {
        	$("#newuser").click(function(){
				$("#fr_opr").load("action/NewUser.php");		
			});
			$("#edituser").click(function(){
				$("#fr_opr").load("action/NewUser.php");		
			});
    	});		
	</script>
           
            <h1 class="page-title">Users</h1>
<div class="btn-toolbar">
    <a href="?tag=adduser" class="btn btn-primary btn-large"><i class="icon-plus"></i>New Room</a>
    <!--<button class="btn">Import</button>
    <button class="btn">Export</button>-->
  <div class="btn-group">
  </div>
</div>

<div class="well">
    <table class="table">
      <thead>
        <tr>
          <th>#</th>
          <th>Employee Name</th>
          <th>Username</th>
          <th>Password</th>
          <th style="width: 26px;"></th>
        </tr>
      </thead>
      <tbody>
        <?PHP 
			$dbhost = 'localhost';
			$dbuser = 'root';
			$dbpass = '';
			 $rec_limit = 5;
			 
			 $opr="";
			 
			 if(isset($_GET['opr']))
				$opr=$_GET['opr'];
			 
			 $conn = mysql_connect($dbhost, $dbuser, $dbpass);
				if(! $conn )
				{
				  die('Could not connect: ' . mysql_error());
				}
				mysql_select_db('hotel');
			$sqlc = "SELECT count(user_id) FROM user_tbl ";
			
						
			$retval = mysql_query( $sqlc, $conn );
			if(! $retval )
				{
				  die('Could not get data: ' . mysql_error());
				}	
			$row = mysql_fetch_array($retval, MYSQL_NUM );
			$rec_count = $row[0];
			
			if( isset($_GET{'page'} ) )
			{
			   $page = $_GET{'page'} ;
			   $offset = $rec_limit * $page ;
			}
			else
			{
			   $page = 0;
			   $offset = 0;
			}
			
			$left_rec = $rec_count - ($page * $rec_limit);
			$sql = "SELECT u.*,e.emp_name FROM user_tbl u INNER JOIN employee_tbl e ON u.emp_id=e.emp_id WHERE u.active=1 " .
				   "LIMIT $offset, $rec_limit ";
				   
			$retval = mysql_query( $sql, $conn );
			if(! $retval )
			{
			  die('Could not get data: ' . mysql_error());
			}
				   
			while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
			{
		 ?>
        <tr>
          <td><?php echo $row['user_id']; ?></td>
          <td><?php echo $row['emp_name']; ?></td>
          <td><?php echo $row['username']; ?></td>
          <td><?php echo $row['password']; ?></td>
          <td>
              <a href="?tag=edituser&uid=<?php echo $row['user_id']; ?>" id="edituser"><i class="icon-pencil"></i></a>
              <a href="#myModal" role="button" data-toggle="modal"><i class="icon-remove"></i></a>
          </td>
        </tr>
        <?php } 
			
				mysql_close($conn);
		?>
        
      </tbody>
    </table>
</div>
<div class="pagination">
    <ul>
        <?php if($rec_count>0){
		$p="";
				
		if(isset($_GET['page']))
			$p=$_GET['page'];
		
		
		$page=$rec_count/5;
		$a=$rec_count%5;
		if($a>0){ $page+=1;}
		?>
		<li><a id="pagen" href="?tag=viewuse&page=<?php if ($p>0){echo $p-1;}else echo 0; ?> " >Prev</a></li>
		<?php
			for($i=0;$i<=$page-1;$i++){	
		?>        
				<li><a id="pagen" href="?tag=viewuse&page=<?php echo $i; ?>"><?php $offset=$i*$rec_limit; echo $i; ?></a></li>               
			
		<?php }} ?>
				
		<li><a id="pagen" href="?tag=viewuse&page=<?php if ($p<$page){echo $p+1;}else echo $page; ?> " >Next</a></li>
    </ul>
</div>